#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
    char buf[50] = {0};
    FILE *fp = NULL;
    int size;

    if(NULL == (fp = fopen(argv[1], "r"))){
        perror("fopen error");
        exit(-1);
    }

    printf("open file \"%s\" success!\n", argv[1]);

    if(12 > (size = fread(buf, 1, 12, fp))){
        if(ferror(fp)){
            printf("fread error!\n");
            fclose(fp);
            exit(-1);
        }
    }

    printf("read file \"%s\" success!\nsize: %d, buffer: %s\n", argv[1],size,buf);
    
    fclose(fp);
    exit(0);
}
